package persistence;

import java.util.ArrayList;

import thriftgenerated.Category;

public class CategoryPersistence {
	private static ArrayList<Category> categorias = new ArrayList<Category>();

	public static void addCategoria(Category category) {
		CategoryPersistence.categorias.add(category);
	}
	
	public static ArrayList<Category> getCategorias(int uid) {
		ArrayList<Category> categoriasByUid = new ArrayList<Category>();
		for (Category cat : CategoryPersistence.categorias) {
			if (cat.getUid() == uid) {
				categoriasByUid.add(cat);
			}
		}
		return categoriasByUid;
	}
	
	public static ArrayList<Category> getCategorias() {
		return categorias;
	}

	public static void setCategorias(ArrayList<Category> categorias) {
		CategoryPersistence.categorias = categorias;
	}

	public static Category getCategoria(int categoryId) {
		Category catResult = null;
		for (Category cat : CategoryPersistence.categorias) {
			if (cat.getCategoryId() == categoryId) {
				catResult = cat;
				break;
			}
		}
		return catResult;
	}

	
}
